FROM buntu:24.04

RUN apt-get update -y && DEBIAN_FRONTEND=noninteractive apt install -y git gcc flex bison gperf make python unzip rar \
	dos2unix swig python-dev python3-dev python3-pip clang-format python3 python3-setuptools python3-wheel ninja-build \
	rename gdb apache2 re2c ctags lzip libncurses-dev tree pkg-config cmake automake lzop doxygen graphviz libssl-dev \
	genromfs lzma texinfo mtools mtd-tools automake libtool sudo zsh sed make libncurses5 libncurses5-dev rsync wget vim curl

# 以下文件需要自行替换为对应开发环境所需的交叉编译器和对应版本的工具
COPY ./mips32-mti-elf /opt/mips32-mti-elf
COPY ./colrm /usr/bin/colrm
COPY ./locale /etc/default/locale

RUN pip3 install fdt; sed -i 's/required/sufficient/g' /etc/pam.d/chsh && echo 'root:admin'| chpasswd; sed -i 's:/bin/sh:/bin/zsh:' /etc/passwd;\
	chmod +x /usr/bin/colrm; chown root:root /usr/bin/colrm; chmod 644 /etc/default/locale;

ENV USER=systech
ENV SHELL=/bin/zsh
ARG USER_ID=0
ARG GROUP_ID=0
RUN groupadd -g ${GROUP_ID} chengyh-docker && useradd -m -g chengyh-docker -u ${USER_ID} systech && usermod -s /bin/zsh systech

USER systech

# 修改 /etc/passwd 文件，为所有用户设置默认的 shell 为 /bin/zsh
RUN sh -c "$(curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh)"; \
	git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions && rm -rf ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions/.git;\
	git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting && rm -rf ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting/.git;\
	git clone --depth=1 https://github.com/zdharma-continuum/fast-syntax-highlighting.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting && rm -rf ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting/.git;\
	git clone --depth=1 https://github.com/romkatv/powerlevel10k ~/.oh-my-zsh/custom/themes/powerlevel10k && rm -rf ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k/.git;\
	git clone --depth=1 https://github.com/DarrinTisdale/zsh-aliases-exa.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-aliases-eza && rm -rf ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-aliases-eza/.git

COPY ./.zshrc /home/systech/
